package com.hbsi.demo1;

/**
 * @author 程奕红
 * @version 1.0
 */
public class Tickets {
    public int tickets;

    public Tickets() {
        tickets=10;
    }
}
class TicketThread extends Thread{
    Tickets t;
    String name;

    public TicketThread(Tickets t,String name) {

        this.t = t;
        this.name = name;
        start();
    }

    @Override
    public void run() {
      for(int i=0;i<5;i++){
          System.out.println(name+"抢到了第"+t.tickets+"号票");
          t.tickets--;
          try {
              Thread.sleep(20);
          } catch (InterruptedException e) {
              throw new RuntimeException(e);
          }
      }
    }
}
